package zFactory;

import org.eclipse.emf.common.util.EList;

import node1.AbstractTask;
import tRM_RTNB.TRM_RTNB;
import tRM_RTNB.TRM_RTNBFactory;
import genArchi.Node;

public class NodeWcrtNB implements NodeInterface {

	/**
	 * Attributes
	 */
	private EList<AbstractTask> l_tasks;
	private boolean enableCreate;
	
	/**
	 * Constructor
	 */
	public NodeWcrtNB(EList<AbstractTask> l_tasks, boolean enableCreate) 
	{
		this.l_tasks =  l_tasks;
		this.enableCreate = enableCreate;
	}

	@Override
	public Node createNode() {
		/**/
		TRM_RTNB rt = TRM_RTNBFactory.eINSTANCE.createTRM_RTNB();

		/**/
		for (AbstractTask t : l_tasks) {

			/**/
			tRM_RTNB.Task lt = TRM_RTNBFactory.eINSTANCE.createTask();
			lt.setId(t.getId());
			lt.setPeriod(t.getPeriod());
			lt.setWcet(t.getWcet());
			lt.setPriority(t.getPriority());
			lt.setDeadline(t.getDeadline());

			/**/
			rt.getTasks().add(lt);
		}

		return rt; 
	}

	@Override
	public String getNodeName() 
	{
		return "tRM_RTNB.impl.TRM_RTNBImpl";
	}

	@Override
	public void update(Node node) {}

	@Override
	public boolean isEnable() 
	{
		return this.enableCreate;
	}

}
